class MinStack:
    def __init__(self):
        self.minstack = []
        self.minelem = [float('inf')]
    def push(self,x):
        self.minstack.append(x)
        self.minelem.append(min(x, self.minelem[-1]))

    def pop(self):
        self.minstack.pop()
        self.minelem.pop()

    def top(self):
        # need not juge if is o
        return self.minstack[-1]

    def getmin(self):

        return self.minelem[-1]


